/**
 * 
 */
package com.nari.heatshare.utils;

import com.nari.heatshare.model.IAssignMeterDataGather;
import com.nari.heatshare.model.IHeatMeterDataGather;
import com.nari.heatshare.model.ITemperaturePointDataGather;
import com.nari.platform.date.CalendarConstants;
import com.nari.platform.date.CalendarUtils;
import com.nari.platform.utils.StringUtils;

/**
 * 热表数据TXT文件生成器
 * @author Xiaopeng
 * @date 2014-5-7
 */
public class MeterDataTxtGenerator {
	
	/**
	 * 分配表数据TXT记录生成
	 * @param meterData
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2014-5-7
	 */
	public static String genAssignMeterDataRecord(IAssignMeterDataGather meterData) throws Exception {
		//拼接热表数据字符串
		StringBuffer meterDataDebugInfo = new StringBuffer("");
		if(meterData != null) {
			//0-集中器号
			meterDataDebugInfo.append(meterData.getConcentratorNo());
			meterDataDebugInfo.append(",");
			//1-分配表序号
			String seriousNum = meterData.getSeriousNum().replaceFirst(meterData.getConcentratorNo(), "");
			meterDataDebugInfo.append(seriousNum);
			meterDataDebugInfo.append(",");
			//2-读数
			String readNum = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getReadNum()).intValue()).toString(), 6);
			meterDataDebugInfo.append(readNum);
			meterDataDebugInfo.append(",");
			//3-上传时间
			String readTime = CalendarUtils.parseDateToString(meterData.getReadTime(), CalendarConstants.dateTimeFormat);
			meterDataDebugInfo.append(readTime);
			meterDataDebugInfo.append(",");
			//4-背板温度
			String backTemp = Integer.valueOf(new Double(meterData.getBackTmperature()).intValue()).toString();
			meterDataDebugInfo.append(backTemp);
			meterDataDebugInfo.append(",");
			//5-前板温度
			String frontTemp = Integer.valueOf(new Double(meterData.getFontTemperature()).intValue()).toString();
			meterDataDebugInfo.append(frontTemp);
			meterDataDebugInfo.append(",");
			//6-去年热量
			String lastYearHeat = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getLastYearHeat()).intValue()).toString(), 6);
			meterDataDebugInfo.append(lastYearHeat);
			meterDataDebugInfo.append(",");
			//7-1月热量
			String oneHeat = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getOneHeat()).intValue()).toString(), 6);
			meterDataDebugInfo.append(oneHeat);
			meterDataDebugInfo.append(",");
			//8-2月热量
			String twoHeat = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getTwoHeat()).intValue()).toString(), 6);
			meterDataDebugInfo.append(twoHeat);
			meterDataDebugInfo.append(",");
			//9-3月热量
			String threeHeat = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getThreeHeat()).intValue()).toString(), 6);
			meterDataDebugInfo.append(threeHeat);
			meterDataDebugInfo.append(",");
			//10-4月热量
			String fourHeat = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getFourHeat()).intValue()).toString(), 6);
			meterDataDebugInfo.append(fourHeat);
			meterDataDebugInfo.append(",");
			//11-5月热量
			String fiveHeat = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getFiveHeat()).intValue()).toString(), 6);
			meterDataDebugInfo.append(fiveHeat);
			meterDataDebugInfo.append(",");
			//12-10月热量
			String tenHeat = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getTenHeat()).intValue()).toString(), 6);
			meterDataDebugInfo.append(tenHeat);
			meterDataDebugInfo.append(",");
			//13-11月热量
			String elevenHeat = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getElevenHeat()).intValue()).toString(), 6);
			meterDataDebugInfo.append(elevenHeat);
			meterDataDebugInfo.append(",");
			//14-12月热量
			String twelveHeat = StringUtils.leftPad(Integer.valueOf(new Double(meterData.getTwelveHeat()).intValue()).toString(), 6);
			meterDataDebugInfo.append(twelveHeat);
			meterDataDebugInfo.append(",");
			//15-抄表时间
			String recordTime = CalendarUtils.parseDateToString(meterData.getRecordTime(), CalendarConstants.dateTimeFormat);
			meterDataDebugInfo.append(recordTime);
		}
		return meterDataDebugInfo.toString();
	}
	
	/**
	 * 热量表数据TXT记录生成
	 * @param meterData
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2014-5-7
	 */
	public static String genHeatMeterDataRecord(IHeatMeterDataGather meterData) throws Exception {
		
		return null;
	}
	
	/**
	 * 温度点数据TXT记录生成
	 * @param meterData
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2014-5-7
	 */
	public static String genTempPointDataRecord(ITemperaturePointDataGather meterData) throws Exception {
		
		return null;
	}
}
